// import axios from "axios";
import { http } from '@/utils'
export default {
    namespaced:true,
    state:{
        cinemas:[],
        cityId:440100 , //城市id
        cinemaId:4592 ,  //影院id
        kValue:6426551,
        cinemaDetails:[],
        detailsList:[],
        cinedetailsVal:7837238,
        CinemaData:[] ,//轮播图数据
        MovieRunTime:[]
    },
    mutations:{
        //获取城市列表数据
        setCityId(){

        },
        //全部影院
        setCinema(state,cinemas){
            state.cinemas = cinemas
        },
        //影院详情
        setCinemaDetails(state,cinemaDetails){
            state.cinemaDetails = cinemaDetails
        },
        //电影详情图片
        setDetailsList(state,detailsList){
            state.detailsList = detailsList
        },

        //设置影院数据
        setCinemaDeteilsData(state,CinemaData){
            state.CinemaData = CinemaData
        },
        //电影排放方式
        setMovieRouTime(state,MovieRunTime){
            state.MovieRunTime = MovieRunTime
        }
    },
    actions:{

        // 获取影院id
        async  getCinema({commit},cityId){
            await  http.get(`https://m.maizuo.com/gateway?cityId=${cityId}&ticketFlag=1&k=5652876`,{
                headers: {
                    "X-Client-Info":
                      '{"a":"3000","ch":"1002","v":"5.0.4","e":"16276534206037753355567105","bc":"440100"}',
                    "X-Host": "mall.film-ticket.cinema.list",
                  },
            }).then(res =>{
                commit('setCinema',res.data.data.cinemas)
                // console.log(res.data.data.cinemas);
                
            })
        },
        
        async getCinemaDetails({commit,state},cineId){
            await http.get(`https://m.maizuo.com/gateway/?cinemaId=${cineId}&k=${state.kValue}`,{
                headers: {
                    "X-Client-Info":
                      '{"a":"3000","ch":"1002","v":"5.0.4","e":"16276534206037753355567105","bc":"440100"}',
                    "X-Host": "mall.film-ticket.cinema.info",
                  },
            }).then(res =>{
                commit('setCinemaDetails',res.data.data.cinema) 
            })

            
        },
        // //获取电影详情图片
        async getDetailsList({commit},cinemaID){
            await http({
                url:`https://m.maizuo.com/gateway/?cinemaId=${cinemaID}&k=7645325`,
                    headers:{
                        "X-Client-Info": '{"a":"3000","ch":"1002","v":"5.0.4","e":"16276534206037753355567105","bc":"440100"}',
                        'X-Host':'mall.film-ticket.film.cinema-show-film'
                    }
            }).then(res =>{
                console.log(res.data.data);
                commit('setCinemaDeteilsData',res.data.data)
            })
        },
        //获取电影排放时间
        async getMovieRouTime({commit,state},filmId,cinemaId){
            await http.get(`https://m.maizuo.com/gateway/?filmId=${filmId}&cinemaId=${state.cinemaId}&date=1628179200&k=6589096`,{
                headers:{
                    "X-Client-Info":'{"a":"3000","ch":"1002","v":"5.0.4","e":"16276534206037753355567105","bc":"440100"}',
                    "X-Host":'mall.film-ticket.schedule.list'
                }
            }).then(res =>{
                commit('setMovieRouTime',res.data.data) //schedules
                
            })
        }
        
        
        
    }
}